<template>
	<view class="content" style="background-color: #F7F7F7;min-height:100vh">
		<activity-list :activityList="activityList"></activity-list>
		<mix-load-more :status="loading"></mix-load-more>
	</view>
</template>

<script>
import http from '../common/request.js';
import activityList from './components/activity-list.vue';
import mixLoadMore from '@/components/mix-load-more/mix-load-more';
import {getCommonShareInfo} from '@/common/utils.js'
export default {
	components: {
		activityList,
		mixLoadMore
	},
	data() {
		return {
			inputText: '',
			TabCur: 0,
			memberId: '',
			tabList: [
				{
					name: '全部'
				},
				{
					name: '未开始'
				},
				{
					name: '进行中'
				},
				{
					name: '已结束'
				}
			],
			activityList: [],
			loading: 0,
			pageNum: 1,
			pageSize: 10
		};
	},
	onReachBottom: function() {
		//当划到最底部的时候触发事件
		if (this.loading != 2) {
			this.onLoadList(); //到底之后会触发getMoreNews()函数;
		}
	},
	onShareAppMessage() {
		return getCommonShareInfo()
	},
	mounted() {
		this.onLoadList();
	},
	methods: {
		onLoadList: function(value) {
			this.loading = 1;
			http('/api/activity/appActivityList', {
				method: 'GET',
				data: {
					search: this.inputText,
					activityStatus: value,
					pageNum: this.pageNum,
					pageSize: this.pageSize
				}
			}).then(result => {
				if (result.code == 200) {
					var pages = result.data || [];
					this.activityList = this.activityList.concat(pages); //进行数据的累加
					if (pages.length == this.pageSize) {
						this.pageNum++; //页数的++
						this.loading = 0;
					} else {
						this.loading = 2;
					}
					this.loading = this.activityList.length === 0 ? 3 : this.loading;
				}
			});
		}
	}
};
</script>

<style scoped>
.search-bar {
	/* #ifndef APP-NVUE */
	display: flex;
	/* #endif */
	flex-direction: row;
	position: relative;
	padding: 16rpx;
	background: #ffffff;
}
.exploreMore {
	font-size: 26rpx;
}
.search-bar-box {
	/* #ifndef APP-NVUE */
	display: flex;
	box-sizing: border-box;
	/* #endif */
	overflow: hidden;
	position: relative;
	flex: 1;
	justify-content: flex-start;
	flex-direction: row;
	align-items: center;
	padding: 10rpx;
	border-width: 0.5px;
	border-style: solid;
	border-color: #c8c7cc;
	border-radius: 50rpx;
	color: rgba(138, 140, 141, 1);
}
.tabClass {
	color: rgba(138, 140, 141, 1);
	font-size: 26rpx;
	background: #ffffff;
}

.tabSelect {
	font-weight: 400;
	color: rgba(102, 100, 93, 1);
	position: relative;
	border-bottom: 0 !important;
}

.tabSelect::after {
	content: '1111';
	width: 40rpx;
	height: 6rpx;
	background: rgba(102, 100, 93, 1);
	border-radius: 5rpx;
	display: block;
	position: absolute;
	bottom: 0;
	content: '';
	left: 40%;
}

.navbar {
	border: 0;
}
</style>
